home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / WASTE 1.0a4 Distribution / Demo Source / DialogUtils.p next >
Text File  |  1994-01-04  |  1KB  |  61 lines

  1. unit DialogUtils;
  2.  
  3. { WASTE DEMO PROJECT: }
  4. { Dialog Utilities }
  5.  
  6. { Copyright © 1993-1994 Merzwaren }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.  
  11.     function DialogFilter (dialog: DialogPtr;
  12.                                     var event: EventRecord;
  13.                                     var item: Integer): Boolean;
  14.  
  15. implementation
  16.     uses
  17.         DialogExtensions;
  18.  
  19.     procedure DoWindowEvent (var event: EventRecord);
  20.     external;        { defined in DemoEvents.p }
  21.  
  22.     function CallStdFilterProc (dialog: DialogPtr;
  23.                                     var event: EventRecord;
  24.                                     var item: Integer;
  25.                                     filterProc: ProcPtr): Boolean;
  26.     inline
  27.         $205F,                    { movea.l (sp)+, a0 }
  28.         $4E90;                    { jsr (a0) }
  29.  
  30.     function DialogFilter (dialog: DialogPtr;
  31.                                     var event: EventRecord;
  32.                                     var item: Integer): Boolean;
  33.         var
  34.             savePort: GrafPtr;
  35.             standardFilter: ProcPtr;
  36.             err: OSErr;
  37.     begin
  38.         DialogFilter := false;
  39.  
  40. { set up thePort }
  41.         GetPort(savePort);
  42.         SetPort(dialog);
  43.  
  44. { intercept window events directed to windows behind the dialog }
  45.         if (event.what in [updateEvt, activateEvt]) then
  46.             if (WindowPtr(event.message) <> dialog) then
  47.                 DoWindowEvent(event);
  48.  
  49. { tell the Dialog Manager to care about the default item }
  50.         err := SetDialogDefaultItem(dialog, DialogPeek(dialog)^.aDefItem);
  51.  
  52. { call the standard Dialog Manager filter procedure }
  53.         if (GetStdFilterProc(standardFilter) = noErr) then
  54.             DialogFilter := CallStdFilterProc(dialog, event, item, standardFilter);
  55.  
  56. { restore thePort }
  57.         SetPort(savePort);
  58.  
  59.     end;  { DialogFilter }
  60.  
  61. end.